package com.adarsh.f1.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.transaction.annotation.Transactional;

import com.adarsh.f1.base.BaseModel;
import com.adarsh.f1.dao.inf.TeamDao;

@Transactional
public class TeamDaoImpl implements TeamDao {
	
	@PersistenceContext
	EntityManager entityManager;

	@Override
	public boolean insert(BaseModel baseModel) {
		entityManager.persist(baseModel);
		return false;
	}

	@Override
	public List<BaseModel> getAllTeam() {
		Query teamQuery = entityManager.createQuery("SELECT c FROM Team c");
		return  teamQuery.getResultList();
	}

	@Override
	public BaseModel find(Class< ? extends BaseModel> baseClass, long teamId) {
		return entityManager.find(baseClass, teamId);
	}

}
